<template>
	<view class="xy-goods m-lr-30 flex">
		<block v-for="item in goodsList" :key="item.id">
			<xy-goods-grad :item="item" />
		</block>
	</view>
</template>
<script>
	import { mapState } from 'vuex';
	import xyGoodsGrad from './grad';
	export default {
		name: "xy-goods",
		components: {
			xyGoodsGrad,
		},
		props: {
			data: {
				type: Object,
				default: function() {
					return {
						name: '商品组件',
						type: 'goods',
						params: [],
						data: []
					}
				}
			}
		},
		data() {
			return {

				goodsList: []
			};
		},
		created() {
			this.loadData()
		},
		methods: {
			async loadData() {
				let ids = [],data = this.data.data;
				for(let i = 0; i < data.length; i++) {
					ids.push(data[i].goods_id);
				};
				console.log({ids: ids.join(',')})
				this.$api.get({
					url: '/goods/lists',
					data: {ids: ids.join(',')},
					success: res => {
						console.log(res);
						this.goodsList = res;
					}
				});
			},
			async onLink(url){
				this.$xyfun.to(url);
			}
		}
	}
</script>
<style lang="scss">
	.xy-goods{
		xy-goods-grad:nth-child(2n){margin-left: auto;}
		.xy-goods-grad:nth-child(2n){margin-left: auto;}
	}
	
</style>
